/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import static DAO.BaseDAO.abrirConexao;
import static DAO.BaseDAO.conn;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.Cliente;


/**
 *
 * @author Hiran
 */
public class ClienteDAO extends BaseDAO{
    
    public static List<Cliente> filtrarCliente(String cpfCliente) throws Exception {
        PreparedStatement stmt = null;
        ResultSet rs = null;
        List<Cliente> lista_cliente = new ArrayList<>();
        try {
            abrirConexao();
            String sql = "select * from cliente where cpf = ?";
            stmt = conn.prepareStatement(sql);
            stmt.setString(1, cpfCliente);
            rs = stmt.executeQuery();
            while (rs.next()) {
                lista_cliente.add(
                        new Cliente(
                        rs.getString("cpf"),
                        rs.getString("nomecliente"),
                        rs.getString("telefone"),
                        rs.getString("endereco")));

            }

        } finally {
            fecharConexao();
        }
        return lista_cliente;

    }
}
